package com.tengfei.blogsystem.dao;

import com.tengfei.blogsystem.pojo.Category;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;

/**
 * @version v1.0
 * @author} feige
 * @date 2021-10-21-15:34
 * @description
 */
public interface CategoryDao extends JpaRepository<Category, String>, JpaSpecificationExecutor<Category> {

    Category findOneById(String categoryId);

    @Modifying
    @Query(nativeQuery = true, value = "update `tb_categories` set `status`='0',`update_time`=? where `id`=? ")
    int deleteByUpdateStatus(Date update, String categoryId);
}

